module.exports = class extends baseController{
    constructor(){
        super();
        this.settingLogic=this.loadLogic("cms/setting");
        this.router.post('/getInfo',this.getInfo.bind(this));
        this.router.post('/setInfo',this.setInfo.bind(this));
        return this.router;
    }

    

    async getInfo(req,res){
        let Result={};
        try {
            let label=req.body.label || '';
            let siteInfo=await this.settingLogic.getInfo(label);
            Result=this.Success(1,siteInfo);
        } catch (err) {
            Result=this.Error("发布失败",err);
        }
        res.json(Result);
    }

    async setInfo(req,res){
        let Result={};
        try {
            let label=req.body.label || '';
            let model=req.body.model;
            if(model && model!==''){
                model=JSON.parse(model);
            }
            let ret =await this.settingLogic.setInfo(label,model);
            Result=this.Success(1,ret);
        } catch (err) {
            Result=this.Error("发布失败",err);
        }
        res.json(Result);
    }


};